<%@page import="javax.swing.tree.RowMapper"%>
<%@page import="java.util.function.Supplier"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.hgl.entity.Hgl"%>
<%@page import="java.util.List"%>
<%@ page language="java" pageEncoding="UTF-8"%><!DOCTYPE html>
<html>
  <head>
    <title></title>
	<jsp:include page="/admin/head.jsp"/>
  </head>
  <body>
	<jsp:include page="/admin/header.jsp"/>
	<jsp:include page="/admin/left-menu.jsp"><jsp:param value="1" name="index"/></jsp:include>
	<jsp:include page="/admin/footer.jsp"/>



    <!--中间-->
    <section>
      <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
          <li class="breadcrumb-item">管理首页</li>
          <li class="breadcrumb-item">内容管理</li>
          <li class="breadcrumb-item active">新闻中心</li>
        </ol>
      </nav>
      
      <form class="form-inline">
        <div class="form-group mx-sm-1 mb-2">
          <label class="sr-only">新闻类别：</label>
          <select class="form-control">
            <option value="">全部</option>
          </select>
        </div>
        <div class="form-group mx-sm-1 mb-2">
          <label class="sr-only">关键字：</label>
          <input type="text" class="form-control" placeholder="搜索关键字">
        </div>
        <button type="submit" class="btn btn-primary mb-2"><i class="fa fa-search"></i></button>
        <a href="admin/user-add-form.jsp" class="btn btn-success ml-auto mr-2"><i class="fa fa-plus"></i></a>
         <div class="form-group mx-sm-1 mb-2"> 
          <label class="sr-only">数量：</label>
          <select id="numSelect" class="form-control">
          	<option value="">显示条数</option>
            <option value="5"  >每页5条</option>
            <option value="10" >每页10条</option> 
            <option value="20">每页20条</option>
            <option value="50">每页50条</option>
          </select>
        </div>
      </form>
      
<div class="ml-2 mr-2">
<table class="table table-striped table-bordered table-hover">
  <thead>
    <tr>
      <th scope="col">#</th> 
      <th scope="col">名字</th>
      <th scope="col">密码</th>
      <th scope="col">电话号码</th>
      <th scope="col">生日</th>
      <th scope="col">操作</th>
    </tr>
  </thead>
  <tbody>
  <%
  List<Hgl> list = (List<Hgl>)request.getAttribute("list");
	  for(int i=0;i<list.size();i++){
		  Hgl vo=list.get(i);
		  pageContext.setAttribute("vo", vo);
		  pageContext.setAttribute("i", i);
  %>
    <tr>
     <th scope="row">${i+1}</th>
      <td>${vo.hglName}</td>
      <td>${vo.hglGrade }</td>
      <td>${vo.hglTel }</td>
      <td>${eltool.formatDate(vo.hglBirth)}</td>
      
      <td class="p-1"><div class="dropdown">
  <button class="btn btn-outline-primary btn-block dropdown-toggle" type="button" data-toggle="dropdown">
    操作
  </button>
  <div class="dropdown-menu dropdown-menu-right">
    <a class="dropdown-item" target="_blank"  href="admin/user-look.let?hglId=<%=vo.getHglId()%>">查看</a>
    <a class="dropdown-item" href="admin/user-update-form.let?hglId=<%=vo.getHglId()%>">修改</a>
    <a class="dropdown-item _delete" data-index="" href="admin/msg.let?hgl_id=<%=vo.getHglId()%>">删除</a>
  </div>
</div></td>
    </tr>
   <%} %>
  </tbody>
</table>



<%

int rowMax=5;
int total = (int)request.getAttribute("total");
int pageMax=(total-1)/rowMax+1;
String url = "admin/user-list1.let?rowMax={rowMax}&current={current}";
int current = 1;
try{
    rowMax=Integer.valueOf(request.getParameter("rowMax"));
	current = Integer.valueOf(request.getParameter("current"));
}catch(Exception ex){
}
%>
<ul class="pagination justify-content-center">
	<li class="page-item"><a class="page-link" href="<%=url.replace("{rowMax}", rowMax+"").replace("{current}", "1")%>"> <span aria-hidden="true">&laquo;</span></a></li>
<%for(int i=1;i<=pageMax;i++) { %>
	<li class="page-item <%=current==i?"active":""%>"><a class="page-link" href="<%=url.replace("{rowMax}", rowMax+"").replace("{current}", i+"")%>"><%=i %></a></li>
<%} %>
	<li class="page-item"><a class="page-link" href="<%=url.replace("{rowMax}", rowMax+"").replace("{current}", pageMax+"")%>"> <span aria-hidden="true">&raquo;</span></a></li>
</ul>	

</div>
    </section>
    <div class="modal fade" id="confirmDialog" tabindex="-1">
  <div class="modal-dialog">	
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">确认对话框</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        您确定要删除这条记录吗？		
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
        <a href="#" class="btn btn-primary">确定</a>
      </div>
    </div>
  </div>
</div>   
<script type="text/javascript">

$("._delete").on("click",function(){
	let $this = $(this);
	sys.confirm("您需要删除这条记录吗？",function(ret){
		if(ret){
			location = $this.attr("href");
		}
		
	});
	return false;
});


var numSelect = document.getElementById("numSelect");
numSelect.onchange = function(){
	window.location="admin/user-list1.let?rowMax="+this.value+"&current=1";
	
}
</script>


  </body>
</html>
<%!
	//private  SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
	private ThreadLocal<SimpleDateFormat> format = ThreadLocal.withInitial(new Supplier<SimpleDateFormat>(){
		public SimpleDateFormat get(){
			return new SimpleDateFormat("yyyy-MM-dd HH:mm");
		}
	});

	private String format(Date date){
		if(date==null){
			return "-";
		} else {
			return format.get().format(date);
		}
	}

%>


